<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>PHP操作MySQL</title>
    <style>
        .s{
            font-size: 20px;
        }
    </style>
</head>
<body>

<?php
/*
$conn=mysqli_connect('192.168.0.109','chen','5920');
if(!$conn){
    echo '连接失败<br/>';
    echo '错误代码：'.mysqli_connect_errno().'，错误信息：'.mysqli_connect_error().'<br/>';
}else{
    echo '连接成功';
    if(mysqli_select_db($conn,'cpl')) {
        mysqli_select_db($conn, 'utf8');  //设置编码

        $output = mysqli_query($conn, 'select * from userinfo');
        var_dump($output);
        echo '<hr/>';

        while($arr=mysqli_fetch_assoc($output)){
            echo 'ID：'.$arr['id'].',名字：'.$arr['name'].',金钱'.$arr['money'].'<br/>';
        }
        echo '查询的条数：'.mysqli_num_rows($output).'<br/>';
//        for($i=0;$i<1;$i++) {
            $output = mysqli_query($conn, 'insert into test(title, tmp)values("kali","today1")');
//        }
        echo '插入的条数：'.mysqli_affected_rows($conn).'<br/>';

        $output=mysqli_query($conn,"delete from test where id between 56 and 1147");
        echo '删除的条数：'.mysqli_affected_rows($conn).'<br/>';

        //修改数据update
        $output=mysqli_query($conn,"update test set tmp='chen love yxy' where id=48");
        echo '修改的条数：'.mysqli_affected_rows($conn);

        $output=mysqli_query($conn,"select tmp from test where id=51");
        echo mysqli_fetch_assoc($output)['tmp'];

        mysqli_free_result($output);      //释放结果集
//        print_r(mysqli_fetch_array($output));
//        print_r(mysqli_fetch_array($output));
//        print_r(mysqli_fetch_all($output));

//        print_r(mysqli_fetch_assoc($output));
//        print_r(mysqli_fetch_array($output));

//    print_r(mysqli_fetch_array($output));
    }else{
        echo '选择库失败<br/>';
        echo '错误代码：'.mysqli_connect_errno().'，错误信息：'.mysqli_connect_error().'<br/>';

    }

    mysqli_close($conn);
}
*/






if($conn=mysqli_connect("chenpl.xyz",'chen','5920','cpl')){
    mysqli_select_db($conn,'utf8');
    if($result=mysqli_query($conn,"select * from test")){
        while($arr=mysqli_fetch_assoc($result)){
            echo 'name：'.$arr['name'].'，password：'.$arr['pwd'].'<br/>';
        }
        mysqli_free_result($result);
    }else{
        echo '查询错误';
    }
    mysqli_close($conn);
}else{
    echo 'connect failed error code:'.mysqli_connect_errno().' error info:'.mysqli_connect_error();

}















?>

 <img src="./cpl.jpeg">

</body>
</html>





